﻿namespace CSharpTest
{
    public class MqttMessageModel<T>
    {
        /// <summary>
        /// 设备ID
        /// </summary>
        [JsonPropertyName("devid")]
        public string DeviceCode { get; set; } = "";
        /// <summary>
        /// 设备类型
        /// </summary>
        [JsonPropertyName("type")]
        public DeviceType DeviceType { get; set; }
        /// <summary>
        /// 功能码
        /// </summary>
        [JsonPropertyName("code")]
        public FunctionCode FunctionCode { get; set; }
        /// <summary>
        /// 数据流水号
        /// </summary>
        [JsonPropertyName("sn")]
        public int DataSerialNumber { get; set; }
        /// <summary>
        /// 剩余包数量
        /// </summary>
        [JsonPropertyName("nrp")]
        public int NumberOfRemainingPackets { get; set; }
        /// <summary>
        /// 设备运动方向，管带不考虑
        /// </summary>
        [JsonPropertyName("dir")]
        public int MotorDirection { get; set; }
        /// <summary>
        /// 设备运行模式，管带不考虑
        /// </summary>
        [JsonPropertyName("mode")]
        public int RunningMode { get; set; }
        /// <summary>
        /// 软件硬件版本信息
        /// </summary>
        [JsonPropertyName("version")]
        public int Version { get; set; }
        /// <summary>
        /// 具体数据内容
        /// </summary>
        [JsonPropertyName("data")]
        public List<T> Data { get; set; } = new List<T>();
    }

    public class SensorDataPackage
    {
        /// <summary>
        /// 故障状态码
        /// </summary>
        [JsonPropertyName("status")]
        public TubeBeltState Status { get; set; }
        /// <summary>
        /// 触发器位置
        /// </summary>
        [JsonPropertyName("wrappingloc")]
        public int GapLocation { get; set; }
        /// <summary>
        /// 传感器原始值
        /// </summary>
        [JsonPropertyName("sensordata")]
        public List<int> SensorDataList { get; set; }= new List<int>();
    }

    /// <summary>
    /// 设备类型
    /// </summary>
    public enum DeviceType
    {
        /// <summary>
        /// 管带设备
        /// </summary>
        TubeBelt = 1,
        /// <summary>
        /// 皮带定位设备
        /// </summary>
        BeltLocation = 2,
        /// <summary>
        /// 焦化机器人设备
        /// </summary>
        CokingRobot = 3,
        /// <summary>
        /// 保留
        /// </summary>
        Reserve = 4
    }

    /// <summary>
    /// 功能码
    /// </summary>
    public enum FunctionCode
    {
        /// <summary>
        /// 配置信息查询
        /// </summary>
        ConfigQuery = 1,
        /// <summary>
        /// 相关参数配置
        /// </summary>
        ParamsConfig = 2,
        /// <summary>
        /// 获取数据内容
        /// </summary>
        ObtainData = 3,
        /// <summary>
        /// 控制停带
        /// </summary>
        ControllStopingBelt = 4,
        /// <summary>
        /// 主动数据上报
        /// </summary>
        ActiveReport = 5,
        /// <summary>
        /// 设备复位
        /// </summary>
        DeviceReset = 10,
        /// <summary>
        /// 远程升级
        /// </summary>
        RemoteUpgrade = 20
    }

    /// <summary>
    /// 皮带故障状态
    /// </summary>
    [Flags]
    public enum TubeBeltState
    {
        /// <summary>
        /// 扭管
        /// </summary>
        Downward = 1,
        /// <summary>
        /// 反包
        /// </summary>
        ReverseWrap = 2,
        /// <summary>
        /// 胀管
        /// </summary>
        Swollen = 4,
        /// <summary>
        /// 塌管
        /// </summary>
        Collapsed = 8,
        /// <summary>
        /// 网络掉线
        /// </summary>
        Error= 16,
    }
}
